package com.xhs.repository;

import com.xhs.entity.Content;
import com.xhs.entity.Like;
import com.xhs.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Optional;

/**
 * 点赞数据访问接口
 */
@Repository
public interface LikeRepository extends JpaRepository<Like, Long> {
    
    /**
     * 查找用户对特定内容的点赞记录
     */
    Optional<Like> findByUserAndContent(User user, Content content);
    
    /**
     * 检查用户是否已点赞某内容
     */
    boolean existsByUserAndContent(User user, Content content);
    
    /**
     * 删除用户对特定内容的点赞
     */
    void deleteByUserAndContent(User user, Content content);
    
    /**
     * 统计内容的点赞数
     */
    long countByContent(Content content);
} 